export const PlayerMiniMixin = {
  data () {
    return {
      PlayerHeight: 60
    }
  },
  computed: {
    showPlayer () {
      return !!this.$store.state.player.playList.length
    }
  }
}

export const PlayerMiniRefreshMixin = {
  activated () {
    this.$refs.scroll && this.$refs.scroll.refresh()
  },
  watch: {
    showPlayer () {
      setTimeout(() => {
        this.$refs.scroll && this.$refs.scroll.refresh()
      }, 30)
    }
  },
  computed: {
    showPlayer () {
      return !!this.$store.state.player.playList.length
    }
  }
}

export const WatchBack = {
  mounted () {
    // window.history.pushState(null, null, document.URL)
    window.addEventListener('popstate', this.onBrowserBack, false)
  },
  methods: {
    addHistory () {
      window.history.pushState(null, null, document.URL)
    },
    removeHistory () {
      window.history.back()
    },
    onBrowserBack (e) {
      console.log(e)
    }
  },
  destroyed () {
    // 当页面销毁必须要移除这个事件，vue不刷新页面，不移除会重复执行这个事件
    window.removeEventListener('popstate', this.onBrowserBack, false)
  }
}
